var htmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');
/*
module.exports = {
	devtool: 'eval-source-map',
//	entry: './src/js/main.js',
	entry:{
		main:'./src/js/main.js',
		a:'./src/ccav/a.js',
		b:'./src/ccav/b.js',
		c:'./src/ccav/c.js'
	},
	output: {
		path: __dirname + "/dist", //打包后的文件存放的地方
		filename: "js/[name]-[hash].js", //打包后输出文件的文件名
		publicPath:"https://www.ccav.com"
	},
	plugins: [
		new htmlWebpackPlugin({
			filename:'a.html',
			template: 'index.html',//指定打包后的html模板
			inject:'head',//js在头部引入
			title:'webpack is a',
			chunks:['main','a']//指定要引入哪几个入口的js
		}),
		new htmlWebpackPlugin({
			filename:'b.html',
			template: 'index.html',//指定打包后的html模板
			inject:'head',//js在头部引入
			title:'webpack is b',
			excludeChunks:['a','main','c']//排除a mian c ，其他的都引入
//			minify:{//压缩HTML代码
//				removeComments:true,//删除注释
//				collapseWhitespace:true,//删除空格
//			}
		}),
		new htmlWebpackPlugin({
			filename:'c.html',
			template: 'index.html',//指定打包后的html模板
			inject:'head',//js在头部引入
			title:'webpack is c',
			chunks:['c']
//			minify:{//压缩HTML代码
//				removeComments:true,//删除注释
//				collapseWhitespace:true,//删除空格
//			}
		})
	]
}
*/
module.exports = {
	entry: './src/app.js',
	output: {
		path: __dirname + '/dist',
		filename: "js/[name].bundle.js"
	},
	plugins: [
		new htmlWebpackPlugin({
			filename: 'index.html',
			template: 'index.html',
			inject: 'body'
		})
	],
	module: {
		rules: [{
			test: /\.m?js$/,
			exclude: /(node_modules|bower_components)/,
			//			exclude:'./node_modules/',//不处理该文件下的东西
			//			include:__dirname+'/src/',
			include: path.resolve(__dirname, 'src'),
			use: {
				loader: 'babel-loader',
				options: {
					presets: ['@babel/preset-env']
				}
			}
		}, {
			test: /\.css$/,
			use: ['style-loader', 
			{
				loader: 'css-loader',
				options: {
					importLoaders: 1
				}
			}, 
			'postcss-loader']
		},{
			test:/\.less$/,
			use:['style-loader','css-loader','postcss-loader','less-loader']
		},
		{
			test:/\.scss$/,
			use:['style-loader','css-loader','postcss-loader','sass-loader']
		},{
			test:/\.html$/,
			loader:"html-loader"
		},{
			test:/\.ejs$/,
			loader:"ejs-loader"
		},{
			test:/\.(png|jpg|gif|svg)$/,
			use:[
				{
					loader:"url-loader",
					options:{
						limit:20000,
						name:'assets/[name]-[hash:5].[ext]'
					}
				},
				'image-webpack-loader'
			]
		}]

	}

}